package vegsan.demos.MyThread;


public class MySecondThread extends Thread {


	public int ElementID;
	
	MySync obj;
	
	
	public MySecondThread(){
		//s = new Thread();
		super.setName("Child Thread");
		//System.out.println("A child thread was created");
		//System.out.println("The child thread info below");
		start();
		
	}	
	
	public MySecondThread(MySync obj){
		this();
		this.obj = obj;
		
	}	
	
	

@Override
public void start() {
	super.start();
} 


//@Override



public void test() throws InterruptedException{

	Thread.sleep(1000);	
	
}


public void run() {
	
	for (int i = 0; i < 10; i++) {
		

		try{ 
		Thread.sleep(1000);
		System.out.println("My Second Thread, Iteration = "+i);
		}	
		
		catch(InterruptedException e){
			System.out.println(e);
			
		}
		//Thread.sleep(1000);		
		synchronized (obj) {
			
		}
	} 
	System.out.println("My Second Thread complited");
	

}
}
